package cn.cau.epidemicsurveysystem.control;

import cn.cau.epidemicsurveysystem.bean.AreaStatisticsBean;
import cn.cau.epidemicsurveysystem.bean.MonthStatisticsBean;
import cn.cau.epidemicsurveysystem.bean.WeekStatisticsBean;
import cn.cau.epidemicsurveysystem.service.StatisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * @projectName: gp2023
 * @package: cn.cau.epidemicsurveysystem.control
 * @className: StatisticsController
 * @author: zy
 * @description: TODO
 * @date: 2022/3/4 9:24
 * @version: 1.0
 */

@RestController
@RequestMapping("/statistics")
public class StatisticsController {
    @Autowired
    StatisticsService statisticsService;

    /**
     * @param type: 需要返回的区域数据类型：0-现有确诊，1-累计治愈，2-累计死亡
      * @return List<AreaStatisticsBean> ：返回对应类型的实体对象List
     * @author zy
     * @description TODO
     * @date 2022/3/4 9:28
     */
    @RequestMapping("/area/{type}")
    public List<AreaStatisticsBean> findAreaDataByType(@PathVariable Integer type){
        return statisticsService.findAreaStatisticsByType(type);
    }

    /**
     * @param cnt: 需要返回的星期周次，2022.2.28~2022.3.06为第一周，2022.3.07~2022.3.13为第二周。以此类推...
    	 * @param type:需要查询数据类型：1-境外输入趋势，2-北京疫情新增趋势
      * @return List<WeekStatisticsBean>
     * @author zy
     * @description TODO
     * @date 2022/3/4 9:30
     */
    @RequestMapping("/week/{cnt}/{type}")
    public List<WeekStatisticsBean> findWeekDataByCntAndType(@PathVariable Integer cnt,@PathVariable Integer type){
        return statisticsService.findWeekStatisticsByCntAndType(cnt,type);
    }

    /**
     * @param year: 需要返回哪一年年份的数据
    	 * @param type: 返回的数据类型，统计数据类型，0-疑似病例，1-重症病例
      * @return List<MonthStatisticsBean>
     * @author zy
     * @description TODO
     * @date 2022/3/4 9:33
     */
    @RequestMapping("/months/{year}/{type}")
    public List<MonthStatisticsBean> findMonthDataByYearAndType(@PathVariable Integer year,@PathVariable Integer type){
        return statisticsService.findMonthStatisticsByYearAndType(year,type);
    }

    @RequestMapping(value = "/getStatisticsData")
    public ModelAndView getStatisticsData(){
        ModelAndView modelAndView=new ModelAndView();

        //各区确诊人数
        List<AreaStatisticsBean> areaStatisticsBeans=statisticsService.findAreaStatisticsByType(0);


        //北京新增
        //月份累计新增
        //地区累计数量

        modelAndView.setViewName("graph_echarts");
        return modelAndView;
    }
}
